home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 27.zip / BS1 part 27 / Condo.V2.04_d3.adf / Decks / MoreExamples / DBBaseDeck.doc < prev    next >
Text File  |  1993-03-08  |  4KB  |  98 lines

  1. About the DBBaseDeck:
  2.  
  3.   On pages 6-24 through 6-25 of the Manual Supplement For CanDo 1.5,
  4.   several routines are defined which a standard DataBase might use.  The
  5.   DBBaseDeck contains these scripts and is designed to allow a user to
  6.   quickly create a running database.
  7.  
  8. How To Use the DBBaseDeck:
  9.  
  10.   Load DBBaseDeck into CanDo 1.5.  The deck already defines a window with
  11.   four buttons on it:  "Next" to move to the next record in the database,
  12.   "Previous" to move to the previous record in the database, "Add" to
  13.   indicate that a record is to be added to the database at the following
  14.   location, and "Delete" which deletes the currently displayed record from
  15.   the database.  There are also two menu items, "Load" and "Save" to load
  16.   and save the database.
  17.  
  18.   At this point, the contents of the records are not defined.  This deck is
  19.   waiting for you to define the records.  To do this, all you need to do is
  20.   add Fields, Document Objects, or Toggle Buttons, etc.  to the window, and
  21.   make sure that the names of these Objects begin with "." (according to
  22.   the rules on page 6-22 of the Supplement manual) and you can define the
  23.   database of your choice.
  24.  
  25.   For example, click on the "ADD" button on CanDo's main panel, and press
  26.   the Field button.  Position the Field on the window somewhere and then
  27.   look at the "Edit a Field" requester.  Change the name of the Field from
  28.   "Field#1" to ".Name", and then press "Okay".  Return to the main panel
  29.   and select "Browse".  Click on the Field which you just created and type
  30.   a name into it.  Then click on the "Add" button on that window.  You will
  31.   notice that the field has been cleared.  Enter another name into the
  32.   field.  Now press the "Next" or "Previous" buttons and you will see the
  33.   name you had typed first.  You have just created a database of two names!
  34.   You can now add other Fields or Documents to the window, naming them in
  35.   the same fashion as you did the .Name field, e.g.  ".Address", ".Phone"
  36.  
  37.   By default, the DBBaseDeck saves the files to "Ram:TestDB.DAT".  You can
  38.   change this by editing the Card's AfterAttachment script.  The next time
  39.   you run the deck, or move to this card, the correct load/save file will
  40.   be used.
  41.  
  42. Adding Features:
  43.  
  44.   Two routines are available within the Deck to allow you to easily add
  45.   buttons to search the DataBase for information ("Search For Entry"), or
  46.   to sort the DataBase using a Key as described on page 6-16 of the
  47.   supplement manual ("Sort DataBase").  These routines implement the
  48.   SearchArray and the SortArray commands in a manner which is consistent
  49.   with the rest of the Deck.  These two routines work in the same manner
  50.   as the routines described on page 6-24 and 6-25 of the supplement manual.
  51.  
  52.   "Search For Entry"
  53.  
  54.     Nop; ARG1 = "Search Value"
  55.     Nop; ARG2 = "Search Key"
  56.     Nop; example - Do "Search For Entry","Henry",".Name"
  57.     Nop
  58.     Let DataBase[Index] = GetDBOBjects                ; Save Current Entry
  59.     SetSearchArrayFlags NOCASE SUBSTRING
  60.     Let OldIndex = Index             ;save index in case Arg1 is not found
  61.     Let Index = SearchArray(DataBase,Arg1,Arg2,Index+1) ;Search next entry
  62.     If Not SearchFound                                 ; Check if found it
  63.       Let Index = SearchArray(DataBase,Arg1,Arg2)  ; search from beginning
  64.       If Not SearchFound
  65.         Let Index = OldIndex              ;not found - goto original index
  66.       EndIf
  67.     EndIf
  68.     Do "Display Entry"     ; Display it!
  69.  
  70.   "Sort DataBase"
  71.  
  72.     Nop ; ARG1 = "Sort key"
  73.     Nop ; example - Do "Sort DataBase",".Name"
  74.     Nop
  75.     Let DataBase[Index] = GetDBOBjects ; Save Entry
  76.     SortArray DataBase,NOCASE STRING ,ARG1 ; Sort Data
  77.     Let Index = FirstArrayIndex(DataBase) ; go to first one
  78.     Do "Display Entry"
  79.  
  80.   If you want to add any other functions, be sure that you are preserving
  81.   and setting the display of the Deck as you go.
  82.  
  83.   For example:
  84.  
  85.     Before changing the display, get the current entry's data as follows:
  86.  
  87.       Let DataBase[Index] = GetDBObjects
  88.  
  89.     After any functions or calls, be sure to update the display as follows:
  90.  
  91.       Do "Display Entry"    ;Display the entry at the current Index.
  92.  
  93.   If you follow this advice, you should have little trouble in expanding
  94.   the features of this deck.
  95.  
  96.   Have fun!
  97.  
  98.